﻿<?php
include("../class/mysql.class.php");
include("../submit/Articles/get_list_article.php");
$obj = new Mysql ();
$pieEntree='[';
$rqq  = "select distinct (id_article) from st_attr_entree WHERE date_add >= '".$_POST['dateD']."' AND date_add <= '".$_POST['dateF']."'";
$rst = mysql_query($rqq);
while($rows = mysql_fetch_object($rst)){ 
  $pieEntree.= "['".getDesignation($rows->id_article)."',".getTotQt($rows->id_article)."],"; 
}
$pieEntree.=']';
$pieSortie='[';
$rqqq  = "select distinct (id_article) from st_attr_sortie WHERE Date_cmd >= '".$_POST['dateD']."' AND Date_cmd <= '".$_POST['dateF']."'";
$rstt = mysql_query($rqqq);
while($rows = mysql_fetch_object($rstt)){ 
  $pieSortie.= "['".getDesignation($rows->id_article)."',".getTotQtSortie($rows->id_article)."],"; 
}
$pieSortie.=']';
?>

<script src="lib/jquery.js"></script>
<script>
var chartCIR;
var chartCIRsortie;
        // globally available 
               
        // Build the chart
        chartCIR = new Highcharts.Chart({
            chart: {
                    renderTo: 'container',
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false
                },
                title: {
                    text: 'Pourcentage Achat articles'
                },
                tooltip: {
                  pointFormat: '{series.name}: <b>{point.percentage}%</b>',
                  percentageDecimals: 1
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            //color: '#000000',
                            //connectorColor: '#000000',
                            formatter: function() {
                                return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
                            }
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: 'Quantité',
                    /*data: [
                        ['Firefox',   45.0],
                        ['IE',       26.8],
                        ['Safari',    8.5],
                        ['Opera',     6.2],
                        ['Others',   0.7],
                    ]*/
                    data: <?php echo $pieEntree?>

                }]
            });
			
			 chartCIR = new Highcharts.Chart({
            chart: {
                    renderTo: 'containerSortie',
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false
                },
                title: {
                    text: 'Pourcentage Vente articles'
                },
                tooltip: {
                  pointFormat: '{series.name}: <b>{point.percentage}%</b>',
                  percentageDecimals: 1
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            //color: '#000000',
                            //connectorColor: '#000000',
                            formatter: function() {
                                return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
                            }
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: 'Quantité',
                    /*data: [
                        ['Firefox',   45.0],
                        ['IE',       26.8],
                        ['Safari',    8.5],
                        ['Opera',     6.2],
                        ['Others',   0.7],
                    ]*/
                    data: <?php echo $pieSortie?>

                }]
            });
	
</script>
    
        <div id='container' style='width: 800px; height: 400px; margin: 0 auto'></div>
		<div id='containerSortie' style='width: 800px; height: 400px; margin: 0 auto'></div>